-
-
Notifications
You must be signed in to change notification settings - Fork 10
Concurrent tasks #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent tasks #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all: it works! This actually speed up compiling-the-compiler a tiny amount in my very limited test :) Great work!
That said, I think there are still a few tweaks that needs to be done.
5a0a78d
to
dbf4acb
Compare
880f5f9
to
2d3dccd
Compare
44d3ae6
to
697858c
Compare
697858c
to
4a40824
Compare
4a40824
to
3c0ac32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do a little better on the documentation, but the implementation and the tests look good to me.
Might be worth waiting on @blaix 's input before making changes.
Would you mind adding your name to |
3c0ac32
to
47e99c8
Compare
47e99c8
to
f9905ea
Compare
The scheduler queue starts to become very slow when a large number of tasks are in flight (Array.shift is O(n) as it needs to reindex the array every time an element is removed). This modifies `_Scheduler_enqueue` to loop through the active procs and resetting the queue when done. Larger arrays (1M+) are now handled more efficiently.
This runs an array of tasks concurrently. If any of them fail the rest of the running tasks are cleaned up.
Because `map2` is now concurrent `Task.sequence` needs to be implemented using `andThen`.
map4+ become less useful as these are just chains of `andMap`. `andMap` runs concurrently as it's defined using `map2`.
f9905ea
to
829df4d
Compare
Thank you for your hard work on this, @andrewMacmurray <3 |
This adds concurrent tasks to gren. The existing
Task
api has been modified to:Task.concurrent
, which runs an array of tasks concurrently.map2
run concurrently.map4
,map5
in favour ofandMap
.The existing
Scheduler
kernel implementation is largely unchanged but with the addition of a_Scheduler_concurrent
helper that spawns multiple processes, handles collecting results and signalling errors.